package com.personal.service.impl;

import com.personal.dao.IndividualDao;
import com.personal.domain.Individual;
import com.personal.service.IndividualService;
import com.personal.util.partDisplay.IndividualPart;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class IndividualServiceImpl implements IndividualService {

    @Autowired
    private IndividualDao individualDao;

    @Override
    public List<Individual> selectAll() {
        return individualDao.selectAll();
    }

    @Override
    public List<IndividualPart> selectPartAll() {
        return individualDao.selectPartAll();
    }

    @Override
    public List<IndividualPart> selectPartByKey(String name,String code) {
        return individualDao.selectPartByKey(name,code);
    }

    @Override
    public boolean add(Individual individual) {
        int flag= individualDao.add(individual);
        if(flag>0)
            return true;
        return false;
    }

    @Override
    public Individual getUpdateData(int id) {
        return individualDao.getUpdate(id);
    }

    @Override
    public boolean update(Individual individual) {
        int flag=individualDao.update(individual);
        if(flag>0)
            return true;
        return false;
    }

    @Override
    public boolean delete(List<Integer> ids) {
        for(int id:ids){
            int flag=individualDao.delete(id);
            if(flag<0)
                return false;
        }
        return true;
    }
}
